package WaiBao;

import java.util.Arrays;

public class YanJing {
    public static void main(String[] args) {
        String[] name = {"王天(班长)", "程思成(副班长)", "小李(学习委员)", "李大华(体育委员)", "王大虎", "小秘", "小明", "小寻", "小阳", "小锤", "张虎", "王德",
                "小型", "小号", "小帅", "小黑", "大白", "大雪", "大虎", "小不点", "大块头", "大胖子", "安其拉", "米莱迪", "李元芳", "燕双鹰", "林青霞", "典韦",
                "许褚", "阎晶(安全委员)"};//考生本人:阎晶(安全委员)
        int[] age = {18, 19, 21, 18, 19, 20, 21, 21, 19, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 20};//考生年龄最后一位：20
        double[] w1 = {78, 88, 85, 90, 88, 69, 78, 99, 60, 80, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 89, 93};
        double[] w2 = {79, 85, 77, 69, 68, 97, 88, 69, 60, 90, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 79, 84, 93};
        double[] w3 = {88, 89, 79, 65, 89, 79, 69, 69, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 94};


        double sum1;//代表每个学生的总分
        double pingjun1;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            sum1 = w1[i] + w2[i] +w3[i];
//            pingjun1 = (sum1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + sum1);
//            System.out.println(name[i] + "的平均分为:" +pingjun1);
//        }


//        double Ret = 0, Avg = 0;
//        double[] chunfang = new double[30];
//        for (int i = 0; i < 30; i++) {
//            Ret = w1[i] + w2[i] + w3[i];
//            pingjun1 = (Ret * 1.0) / 3;
//            chunfang[i] = pingjun1;
//        }
//
//        for (int i = 0; i < chunfang.length - 1; i++) {
//            for (int j = 0; j < chunfang.length - i - 1; j++) {
//                if (chunfang[j] < chunfang[j + 1]) {
//                    double temp = chunfang[j];
//                    chunfang[j] = chunfang[j + 1];
//                    chunfang[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(chunfang[i]);
//        }


        double E1 = 0, E2 = 0, E3 = 0;//计算每门课的平均分
        double F1 = 0, F2 = 0, F3 = 0;//计算每门课标准差
        double G1 = 0, G2 = 0, G3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < w1.length; i++) {
            sum2+=w1[i];
        }
        E1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+E1);
        double Sum = 0;
        for (int i = 0; i < w2.length; i++) {
            Sum+=w2[i];
        }
        E2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+E2);
        double sum = 0;
        for (int i = 0; i <w3.length; i++) {
            sum+=w3[i];
        }
       E3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+E3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < w1.length; i++) {
            c1+= (w1[i] -E1)*(w1[i] - E1);
        }
        F1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+F1);

        for (int i = 0; i < w2.length; i++) {
            c2+= (w2[i] -E2)*(w2[i] - E2);
        }
       F2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+F2);

        for (int i = 0; i < w3.length; i++) {
            c3+= (w3[i] - E3)*(w3[i] - E3);
        }
        F3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+F3);

//        Arrays.sort(w1);
//        Arrays.sort(w2);
//        Arrays.sort(w3);
//        G1 =( w1[15]+w1[16])*1.0/2;
//        G2 =( w2[15]+w2[16])*1.0/2;
//        G3 =( w3[15]+w3[16])*1.0/2;
//        System.out.println("分析化学的中位数为:"+G1);
//        System.out.println("线性代数的中位数为:"+G2);
//        System.out.println("有机化学学的中位数为:"+G3);


    }
}
